package org.example;



import java.io.FileInputStream;
import java.io.IOException;
import java.lang.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Properties;
import java.io.InputStream;
import org.example.InitMethod;

public class Main {
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException {
        String value;
        Properties props = new Properties();

        try (InputStream input =
                     PropertiesLoader.class.getResourceAsStream("/myapp.properties")) {
            if (input == null) {
                return;
            }
            props.load(input);


        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        String myclass=props.getProperty("bootstrapClass");
        try{
            //获得类
            Class<?> clazz;
            clazz=Class.forName(myclass);
            //实例化一个对象
            Object obj=clazz.newInstance();
            //获取方法
            for (Method method : clazz.getDeclaredMethods()){
                if (!method.isAnnotationPresent(InitMethod.class)) {continue;}
                method.setAccessible(true);
                method.invoke(obj);
            }}catch(ReflectiveOperationException e){
            e.printStackTrace();
        }





    }
}

